﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="IndexMany.aspx.cs" Inherits="H2.NET.Web.Management.Config.IndexMany" %>

<%@ Register src="../../UserControls/Pager.ascx" tagname="Pager" tagprefix="uc1" %>
<%@ Register src="../../UserControls/Toolbar.ascx" tagname="Toolbar" tagprefix="uc1" %>
<% var divId = System.Guid.NewGuid().ToString().Replace("-", ""); %>
<div>
<form id="pagerForm" onsubmit="return navTabSearch(this);" action="<%= Request.RawUrl %>" method="post">

    <input type="hidden" name="pageNum" value="<%= PageNumber %>" />
    <input type="hidden" name="numPerPage" value="<%= PageSize %>" />

<div class="pageHeader">
	<div class="searchBar">
		<table class="searchContent">
			<tr>
				<td>
					<label>字典名称：</label><input type="text" name="name" size="30" id="search_name" value="<%= name %>" />
				</td>
			</tr>
		</table>
		<div class="subBar">
            <span class="info_clear">符合条件的记录，共有 <strong><%= TotalItemCount %></strong>条。</span>
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div></li>
                <li><div class="button"><div class="buttonContent"><button type="reset">重置</button></div></div></li>
			</ul>
		</div>
	</div>
</div>
</form>
<form runat="server" id="Form2" onsubmit="return navTabSearch(this);" action="<%= Request.RawUrl %>"
method="post">
<asp:HiddenField runat="server" id="hd_parentId"></asp:HiddenField>
<asp:HiddenField runat="server" id="rel"></asp:HiddenField>
</form>
<div class="pageContent">
    <div class="panelBar" style="border-top: 0;">
        <ul class="toolBar">
            <uc1:toolbar ID="Toolbar1" runat="server" />
        </ul>
    </div>
</div>
<div id="<%=divId %>" style="border:0;">
</div>
<input id="selectedId" type="hidden" />
<script type="text/javascript">

    $(function () {
        var pId = $("#hd_parentId", navTab.getCurrentPanel()).val();
        var name = $("#search_name", navTab.getCurrentPanel()).val();
        $("#<%= divId %>").ligerGrid({
            columns: [
                    { display: 'ID', name: 'ConfigId', hide: 1 },
					{ display: '<b>名称</b>', name: 'Name', align: 'left', width: '200' },
                    { display: '<b>值</b>', name: 'Value', align: 'left', width: '200' },
                    { display: '<b>编码</b>', name: 'Code', align: 'left', width: '200' },
                    { display: '<b>排序</b>', name: 'Seq', align: 'left', width: '200' }
				], height: ($(window).height() - 206),
            allowHideColumn: false, rownumbers: true, colDraggable: true, rowDraggable: true,
            checkbox: false, alternatingRow: false, usePager: false, allowUnSelectRow: true, allowUnSelectRow: true,


            // 设置数据源
            dataAction: 'server', url: "/Management/Config/Handler.ashx?action=GetData&pId=" + pId + "&name=" + name, tree: { columnName: 'Name' },

            // 单击选择行时触发
            onSelectRow: function (rowdata, rowindex, rowDomElement) {
                $("#selectedId", navTab.getCurrentPanel()).val(rowdata.ConfigId);
            },

            // 再次单击选择时出发
            onUnSelectRow: function (data, rowindex, rowobj) {
                $("#selectedId", navTab.getCurrentPanel()).val("");
            }
        });
    });
    function ConfigCreate(url, rel, title) {

        var id = $("#selectedId", navTab.getCurrentPanel()).val();
        var pId = $("#hd_parentId", navTab.getCurrentPanel()).val();
        if (id) {
            $.pdialog.open(url + "?pId=" + id + "&rel="+ pId, rel, title, { width: 550, height: 260, mask: true });
        } else {
            $.pdialog.open(url + "?pId=" + pId + "&rel=" + pId, rel, title, { width: 550, height: 260, mask: true });
        }
        return false;
    }
    function ConfigEdit(url, rel, title) {
        var id = $("#selectedId", navTab.getCurrentPanel()).val();
        var pId = $("#hd_parentId", navTab.getCurrentPanel()).val();
        if (!id) {
            alertMsg.warn("请先选择一条数据！");
            return false;
        }
        if (id) {
            $.pdialog.open(url + "?id=" + id + "&rel=" + pId + "&pId=" + pId, rel, title, { width: 550, height: 260, mask: true });
        } else {
            $.pdialog.open(url + "?id=" + pId + "&rel=" + pId + "&pId=" + pId, rel, title, { width: 550, height: 260, mask: true });
        }
        return false;
    }
    function ConfigDelete(url, rel, title) {
        var id = $("#selectedId", navTab.getCurrentPanel()).val();
        if (!id) {
            alertMsg.warn("请先选择一条数据！");
            return false;
        }
        alertMsg.confirm(title, {
            okCall: function () {
                $.ajax({
                    type: 'POST',
                    url: url,
                    data: { id: id, title: title },
                    dataType: "json",
                    cache: false,
                    success: function (json) {
                        DWZ.ajaxDone(json);
                        navTabSearch($("#pagerForm", navTab.getCurrentPanel()));
                    },
                    error: DWZ.ajaxError
                });

            }
        });
        return false;
    }
</script>
</div>